import { IsString, IsInt, IsOptional } from 'class-validator';
import { Transform } from 'class-transformer';

export class SaveOrderDto {
  @IsOptional() // 可选
  @IsInt()
  @Transform(({ value }) => value || '0') // 缺省时设置默认值
  readonly id: number;

  @IsInt()
  @Transform(({ value }) => value || '0')
  readonly user_id: number;

  @IsOptional()
  @IsString()
  @Transform(({ value }) => value || '')
  readonly user_address: string;

  @IsString()
  @Transform(({ value }) => value || '')
  readonly seller_address: string;

  @IsString()
  @Transform(({ value }) => value || '')
  readonly asset_address: string;

  @IsInt()
  @Transform(({ value }) => value || '0')
  readonly asset_type: number;

  @IsInt()
  @Transform(({ value }) => value || '0')
  readonly token_id: number;

  @IsInt()
  @Transform(({ value }) => value || '1')
  readonly amount: number;

  @IsInt()
  @Transform(({ value }) => value || '0')
  readonly pay_amount: number;
}

export class DelOrderDto {
  @IsInt()
  readonly id: number;

  @IsOptional() // 可选
  @IsString()
  readonly order_no: string;
}
